1. Field of the Invention
The present invention relates to an apparatus and method for generating constant values.
2. Description of the Prior Art
When performing a data processing operation within a data processing apparatus, it is often the case that a constant value is required as one of the input data values for that data processing operation. One known way to provide such a constant value is to encode within a particular instruction an immediate value which can be used to produce that constant value. For example, a move instruction may have encoded therein an immediate value, and execution of the move instruction will cause the immediate value to be expanded as required to the register size of registers within a register file, and then stored within a particular register identified by the move instruction.
As a particular example, in situations where a 32-bit instruction set is used, a certain number of bits of the encoding space, for example 8 bits or 12 bits of the 32-bit instruction, may be used to specify an immediate value. If the register into which the constant value specified by that immediate value to be placed is a 32-bit register, then the immediate value can be zero extended (in the example of an unsigned constant value) or sign extended (in the example of a signed constant value) to 32-bits and then stored within the specified register.
As a further enhancement to the above approach, ARM Limited have provided in their instruction set, an instruction encoding which allows an 8 bit immediate value to be specified, and then a further 4 bits to be specified to identify a rotation to be applied to the immediate value in order to specify its location within a register (with the remaining bits of the register being filled with a predetermined sequence of ones or zeros).
Hence, from the above discussion, it can be seen that there are a number of ways of using an immediate value specified within an instruction to generate particular constant values. However, since there are only a limited number of bits available for specifying an immediate value from which the constant value is to be determined, it will be appreciated that the number of constant values that can be obtained using the above techniques is limited. It would hence be desirable to provide an improved technique for generating constant values for use within the data processing apparatus.
Instructions typically include register specifier fields for identifying source and destination registers for the instruction, a source register holding a source data value for the instruction, and a destination register being a register into which is stored the result data value produced by performing the associated data processing operation. It is also known for an instruction to include a shift specifier field for specifying a shift to be applied to the data identified by a particular one of the register specifier fields, such that the actual input data value is generated by reading the specified register and applying the specified shift to the value read from that register.
In some instruction set architectures, there is also the concept of a “zero register” i.e. a particular value for a register specifier field that, when used in at least some register specifier positions within at least some instructions, causes a value of zero to be read from the register file.